﻿/// <reference path="../../ext-all-debug.js" />
Ext.define('yzmh.controller.Main', {
    extend: 'Ext.app.Controller',

    //stores: ['Users'],

    //models: ['User'],

    views: ['main.Left', 'main.Center'],

    refs: [
       
    ],

    init: function () {
        this.control({
            'viewport > userlist dataview': {
                itemdblclick: this.editUser
            },
            'useredit button[action=save]': {
                click: this.updateUser
            },
            'mainleft > panel > treepanel': {
                itemclick: this.openPanel
            }
        });
    },

    openPanel: function (o, record, item, index, e, eOpts) {
        var tab = o.up("viewport").down('tabpanel');
        var p = tab.down(record.raw.xtype + "[title=" + record.get('text') + "]");
        if (p == null) {
            p = tab.add(Ext.apply(record.raw,{
                title: record.get('text'),
                closable: true,
                autoDestroy: true
            }));
        }
        tab.setActiveTab(p);
    }
});
